//
//  CouponCanUseCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/8/5.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "CouponCanUseCell.h"

@implementation CouponCanUseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [self.bgView pp_clipCorners:UIRectCornerAllCorners radius:6];
        [self.DBgView pp_clipCorners:UIRectCornerAllCorners radius:6];
    });
}

- (void)fillCellWithModel:(CommonCouponModel *)model {
    
    if (model.scoType == CouponType_userNew) {
        self.cutPriceLab.text = @"免单";
    } else {
        self.cutPriceLab.text = [Utilities changeDoubleToString:model.scoCut];
    }
    
    if (model.scoFull == 0) {
        self.conditionLab.text = @"无门槛";
    } else {
        self.conditionLab.text =[NSString stringWithFormat:@"满%@可用",[Utilities changeDoubleToString:model.scoFull]];
    }
    
    self.couponMainTitleLab.text = model.scoName;

//    self.couponTimeLab.text = [NSString stringWithFormat:@"开始日期 %@",model.scoEffectiveStartime];
    self.couponTimeLab.text = [NSString stringWithFormat:@"有效期:%@-%@",model.scoEffectiveStartime,model.scoEffectiveEndtime];

    self.cantUseTimeLab.text = [NSString stringWithFormat:@"适用范围:%@",model.typeName];
        
    if (model.isSel) {
        [self.selectBtn setImage:[UIImage imageNamed:@"common_sel"] forState:UIControlStateNormal];
    } else {
        [self.selectBtn setImage:[UIImage imageNamed:@"common_nor"] forState:UIControlStateNormal];
    }
    
    
    if (model.calSel) {
        self.selectBtn.hidden = NO;
        self.bgView.backgroundColor = UIColorHex(0xff4242);
    } else {
        self.selectBtn.hidden = YES;
        self.bgView.backgroundColor = UIColorHex(0xDEDEDE);
    }
}

@end
